package com.example.tuter.util.httpUtil.HttpFunction;

import com.example.tuter.entity.Message;
import com.example.tuter.entity.PageResult;
import com.example.tuter.entity.Post;
import com.example.tuter.entity.SchoolCookie;
import com.example.tuter.entity.UserInfo;

import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;

public interface UserAPI {


    //不做用户登录，当需要登录时，永远使用学校的信息门户进行登录


    //{{url}}/getUserinfo
    @GET("/user/getUserinfo")
    Call<Message<UserInfo>> getUserInfo();

    //{{url}}/user/updateusername 更新用户昵称
    @POST("/user/updateusername")
    @FormUrlEncoded
    Call<Message<String>> updateUsername(@Field("name") String name);


    //{{url}}/user/checkUsername
    @POST("/user/checkUsername")
    @FormUrlEncoded
    Call<Message<String>> checkUsername(@Field("name") String name);

    //{{url}}/user/mypost
    @POST("/user/mypost")
    @FormUrlEncoded
    Call<Message<PageResult<Post>>> getMyPost(@Field("pageNo") Integer pageNo, @Field("keyword") String keyword);

    //{{url}}/star/:pid
    @GET("/star/{pid}")
    Call<Message<String>> star(@Path("pid") Integer pid);

    //{{url}}/unstar/:pid
    @GET("/collect/unstar/{pid}")
    Call<Message<String>> unStar(@Path("pid") Integer pid);

    //{{url}}/myCollect
    @POST("/myCollect")
    @FormUrlEncoded
    Call<Message<PageResult<Post>>> myCollect(@Field("pageNo") Integer pageNo, @Field("keyword") String keyword);

    //{{url}}/isstar/:pid
    @GET("/isstar/{pid}")
    Call<Message<String>> isStar(@Path("pid") Integer pid);


    //{{url}}/getMessage
    @POST("/getMessage")
    @FormUrlEncoded
    Call<Message<String>> getMessage(@Field("messageId") String messageId);

    //{{url}}/ackMessage
    @POST("/ackMessage")
    @FormUrlEncoded
    Call<Message<String>> ackMessage(@Field("messageId") String messageId);

    @POST("/user/checkUser")
    Call<Message<UserInfo>> checkUser(@Body SchoolCookie schoolCookie);
}
